@using Orchard.Roles.ViewModels

@model RolesIndexViewModel

@{
    Script.Require("ShapesBase");
    Style.Require("FontAwesome");

    Layout.Title = T("Roles").ToString();
}

@using (Html.BeginFormAntiForgeryPost())
{
    @Html.ValidationSummary()
    <fieldset class="bulk-actions">
        <label for="publishActions">@T("Actions:")</label>
        <select id="Select1" name="roleActions">
            <option value="1">@T("Delete")</option>
        </select>
        <button type="submit">@T("Apply")</button>
    </fieldset>
    <div class="manage">@Html.ActionLink(T("Add a role").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
    <fieldset>
        <table class="items" summary="@T("This is a table of the roles currently available for use in your application.")">
            <colgroup>
                <col id="Col1" />
                <col id="Col2" />
                <col id="Col3" />
            </colgroup>
            <thead>
                <tr>
                    <th scope="col"><input type="checkbox" class="check-all" /></th>
                    <th scope="col">@T("Name")</th>
                    <th scope="col"></th>
                </tr>
            </thead>
            @foreach (var row in Model.Rows)
            {
                <tr>
                    <td><input type="checkbox" value="true" name="@("Checkbox." + row.Id)" /></td>
                    <td>
                        @Html.ActionLink(row.Name, "Edit", new { row.Id })
                        @if (Model.RolesWithSecurityCriticalPermissions[row.Name])
                        {
                            <i class="fa-solid fa-triangle-exclamation" style="color: red"
                                title="@T("This role contains security critical permissions.")"></i>
                        }
                    </td>
                    <td>
                        <ul class="action-links">
                            <li class="action-link">
                                @Html.ActionLink(T("Edit").ToString(), "Edit", new { row.Id })
                            </li>
                            @if (row.Name != "Administrator")
                            {
                                <li class="action-link">
                                    <a href="@Url.Action("Delete", new {row.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})"
                                       itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
                                </li>
                            }
                        </ul>
                    </td>
                </tr>
            }
        </table>
    </fieldset>
}